<?php
require_once("includes/dbfunctions.php");

function valid_email($str)
{
    return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
}


if(isSet($_POST['Email']))
{
     $Email = $_POST['Email'];
    $check = checkUser($Email);


    if(mysql_num_rows($check))
    {
        echo '<font color="red">The Email: <STRONG>'.$Email .'</STRONG> is already in use.</font>';
        $error[] = "Email already in use";
    }
    else if(valid_email($_POST['Email']))
    {
        echo 'OK';

    }
    else
    {
        echo '<font color="red">The email you entered is invalid.</font>';
        $error[] = "Email is invalid";
    }
}

if(isSet($_POST['Password']))
{
   echo 'OK';
}

if(isSet($_POST['Confirm_Password']))
{
    echo 'OK';
}

if(isSet($_POST['First'])){
    if(ctype_alpha($_POST['First']) == false){
        echo '<font color="red">The name you have entered is invalid.</font>';
        $error[] = "First name is invalid";
    }
    else
    {
        echo 'OK';
    }

}

if(isSet($_POST['Last'])){
    if(ctype_alpha($_POST['Last']) == false){
        echo '<font color="red">The name you have entered is invalid.</font>';
        $error[] = "Last name is invalid";
    }
    else
    {
        echo 'OK';
    }

}

if(isSet($_POST['Zip'])){
    if(ctype_digit($_POST['Zip'])== false){
        echo '<font color="red">Phone is invalid</font>';
    }
    else
    {
        echo 'OK';
    }
}

if(isSet($_POST['Firstp'])){
    if(ctype_digit($_POST['Firstp'])== false){
        echo '<font color="red">Phone is invalid</font>';
    }
    else
    {
        echo 'OK';
    }
}

if(isSet($_POST['Lastp'])){
    if(ctype_digit($_POST['Lastp'])== false){
        echo '<font color="red">Phone is invalid</font>';
    }
    else
    {
        echo 'OK';
    }
}

?>
